package com.gdziarmaga.webshop.author.model;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.gdziarmaga.webshop.core.dao.GenericDaoImpl;

@Repository("authorRepo")
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public class AuthorDAOImpl extends GenericDaoImpl<Author, Long> implements AuthorDAO {

	@Override
	public Author findProductByAuthor_first_name(String first_name) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Author.AUTHOR_FIRST_NAME, first_name)));
	}

	@Override
	public Author findProductByAuthor_last_name(String last_name) {
		return getObjectByCriteria(createDetachedCriteria().add(Restrictions.eq(Author.AUTHOR_LAST_NAME, last_name)));
	}
}
